package com.example.mapper;

import com.example.model.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {
    User findByUsername(String username);
    User findByPhone(String phone);
    void insert(User user);

    @Update("UPDATE user SET password = #{newPassword} WHERE username = #{username}")
    int updatePassword(@Param("username") String username,
                       @Param("newPassword") String newPassword);

    int updateUsernameByPhone(@Param("phone") String phone,
                              @Param("newUsername") String newUsername);

    int deleteUserByPhone(@Param("phone") String phone);

    @Update("UPDATE user SET  user_pic = #{userPic} WHERE phone = #{phone}")
    int updateUserPicByPhone(@Param("phone") String phone, @Param("userPic") String userPic);

    //    根据手机号查询头像地址
    String selectUser_picByPhone(String phone);

}